<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<script type="text/javascript">
$(function(){
    $('#jquery-accordion').accordion({
        autoHeight: false,
        navigation: true
    });
});
</script>
<form style="margin: auto" action="<?php echo url_for('character/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
<?php if ($form->getObject()->isNew()): ?>
<?php if ($form->hasErrors()): ?>
<div class="ui-state-error" style="padding:5px">
    <span class="bold">Aïe aïe aïe ! C'est pas encore ça...</span>
    <ul class='error'>
    <?php foreach ($form->getGlobalErrors() as $name => $error): ?>
        <li><?php echo $error ?></li>
    <?php endforeach; ?>
    </ul>
    <ul class="error">
       <?php foreach($form as $widget): ?>
        <?php if($widget->hasError()): ?>
            <?php if($widget->getName() == "ktd_character_fiche"){
                foreach($widget as $fwidget){
                    if($fwidget->hasError())
                        echo $fwidget->renderLabel().': '.$fwidget->renderError().'';
                }
            }
            else
              echo $widget->renderLabel().': '.$widget->renderError().'';
        ?>
        <?php endif; ?>
       <?php endforeach; ?>
    </ul>
</div>
<br/>
<?php endif; ?>
<?php ?>
<div id="jquery-accordion" style="text-align:left">
    <h3><a href="#"><?php echo __('Carte d\'identité') ?></a></h3>
    <div>
        <ul class="formRegister">
                <?php foreach ($form as $widget): ?>
                <?php if($widget->getName() != 'ktd_character_fiche') : ?>
                    <?php if (!$widget->isHidden()) { ?>
                        <li>
                            <span>
                                <?php echo $widget->renderLabel(); ?>
                                <?php echo $widget->renderHelp() ?>
                                <?php echo $widget->renderError() ?>
                            </span><br/>
                            <?php echo $widget->render() ?>
                        </li>
                    <?php } else { ?>
                        <li><?php echo $widget->render() ?></li>
                    <?php } ?>
                <?php endif; ?>
                <?php endforeach; ?>
                <?php foreach ($form['ktd_character_fiche'] as $widget): ?>
                <?php if($widget->getName() != 'story' &&
                         $widget->getName() != 'phy_desc' &&
                         $widget->getName() != 'mind_desc' &&
                         $widget->getName() != 'pnj' &&
                         $widget->getName() != 'other') : ?>
                    <?php if (!$widget->isHidden()) { ?>
                        <li>
                            <span>
                                <?php echo $widget->renderLabel(); ?>
                                <?php echo $widget->renderHelp() ?>
                                <?php echo $widget->renderError() ?>
                            </span><br/>
                            <?php echo $widget->render() ?>
                        </li>
                    <?php } else { ?>
                        <li><?php echo $widget->render() ?></li>
                    <?php } ?>
                <?php endif; ?>
                <?php endforeach; ?>
                <input type="submit" value="Save" />
        </ul>
    </div>
<h3><a href="#"><?php echo __('Biographie') ?></a></h3>
    <div>
        <ul class="formRegister">
                    <?php if (!$form['ktd_character_fiche']['story']->isHidden()) { ?>
                        <li>
                            <span>
                                <?php echo $form['ktd_character_fiche']['story']->renderLabel(); ?>
                                <?php echo $form['ktd_character_fiche']['story']->renderHelp() ?>
                                <?php echo $form['ktd_character_fiche']['story']->renderError() ?>
                            </span>
                            <?php echo $form['ktd_character_fiche']['story']->render() ?>
                        </li>
                    <?php } else { ?>
                        <li><?php echo $form['ktd_character_fiche']['story']->render() ?></li>
                    <?php } ?>
                <input type="submit" value="Save" />
        </ul>
    </div>
<h3><a href="#"><?php echo __('Personnalité') ?></a></h3>
    <div>
        <ul class="formRegister">
                    <?php if (!$form['ktd_character_fiche']['mind_desc']->isHidden()) { ?>
                        <li>
                            <span>
                                <?php echo $form['ktd_character_fiche']['mind_desc']->renderLabel(); ?>
                                <?php echo $form['ktd_character_fiche']['mind_desc']->renderHelp() ?>
                                <?php echo $form['ktd_character_fiche']['mind_desc']->renderError() ?>
                            </span>
                            <?php echo $form['ktd_character_fiche']['mind_desc']->render() ?>
                        </li>
                    <?php } else { ?>
                        <li><?php echo $form['ktd_character_fiche']['mind_desc']->render() ?></li>
                    <?php } ?>
                <input type="submit" value="Save" />
        </ul>
    </div>
<h3><a href="#"><?php echo __('Physique') ?></a></h3>
    <div>
        <ul class="formRegister">
                    <?php if (!$form['ktd_character_fiche']['phy_desc']->isHidden()) { ?>
                        <li>
                            <span>
                                <?php echo $form['ktd_character_fiche']['phy_desc']->renderLabel(); ?>
                                <?php echo $form['ktd_character_fiche']['phy_desc']->renderHelp() ?>
                                <?php echo $form['ktd_character_fiche']['phy_desc']->renderError() ?>
                            </span>
                            <?php echo $form['ktd_character_fiche']['phy_desc']->render() ?>
                        </li>
                    <?php } else { ?>
                        <li><?php echo $form['ktd_character_fiche']['phy_desc']->render() ?></li>
                    <?php } ?>
                <input type="submit" value="Save" />
        </ul>
    </div>
<h3><a href="#"><?php echo __('PNJ') ?></a></h3>
    <div>
        <ul class="formRegister">
                    <?php if (!$form['ktd_character_fiche']['pnj']->isHidden()) { ?>
                        <li>
                            <span>
                                <?php echo $form['ktd_character_fiche']['pnj']->renderLabel(); ?>
                                <?php echo $form['ktd_character_fiche']['pnj']->renderHelp() ?>
                                <?php echo $form['ktd_character_fiche']['pnj']->renderError() ?>
                            </span>
                            <?php echo $form['ktd_character_fiche']['pnj']->render() ?>
                        </li>
                    <?php } else { ?>
                        <li><?php echo $form['ktd_character_fiche']['pnj']->render() ?></li>
                    <?php } ?>
                <input type="submit" value="Save" />
        </ul>
    </div>
<h3><a href="#"><?php echo __('Autre') ?></a></h3>
    <div>
        <ul class="formRegister">
                    <?php if (!$form['ktd_character_fiche']['other']->isHidden()) { ?>
                        <li>
                            <span>
                                <?php echo $form['ktd_character_fiche']['other']->renderLabel(); ?>
                                <?php echo $form['ktd_character_fiche']['other']->renderHelp() ?>
                                <?php echo $form['ktd_character_fiche']['other']->renderError() ?>
                            </span>
                            <?php echo $form['ktd_character_fiche']['other']->render() ?>
                        </li>
                    <?php } else { ?>
                        <li><?php echo $form['ktd_character_fiche']['other']->render() ?></li>
                    <?php } ?>
                <input type="submit" value="Save" />
        </ul>
    </div>
</div>
</form>
<?php endif; ?>
<?php if(!$form->getObject()->isNew()): ?>
    <?php echo $form ?>
<?php endif; ?>

